package cn.itcast.service.impl;

import cn.itcast.dao.IncomeDao;
import cn.itcast.service.IncomeService;
import com.alibaba.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.ArrayList;
import java.util.List;

/**
 * 收入查询
 */
@Service(interfaceClass = IncomeService.class)
public class IncomeServiceImpl implements IncomeService {
    @Autowired
    private IncomeDao incomeDao;
    @Override
    public List<Integer> findIncomeCountByMonths(List<String> months) {
        List<Integer> incomeCount = new ArrayList<>();
        for (String month : months) {
            String startDate = month + ".01";
            String endDate = month + ".31";
            Integer count = incomeDao.findIncomeCountBeforeDate(startDate,endDate);
            incomeCount.add(count);
        }
        return incomeCount;
    }
}
